package edu.neu.chenhan.fragment.cooperation;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import edu.neu.chenhan.R;
import edu.neu.chenhan.model.RegistrationForm;

public class RegistrationFormFragment extends Fragment {

    private EditText etCompany, etName, etGender, etPhone, etEmail, etArrivalMethod, etArrivalTrain, etArrivalTime;
    private Button btnSubmit;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.activity_attendance_form, container, false);

        etCompany = view.findViewById(R.id.et_company);
        etName = view.findViewById(R.id.et_name);
        etPhone = view.findViewById(R.id.et_phone);
        etEmail = view.findViewById(R.id.et_email);
        etArrivalMethod = view.findViewById(R.id.et_arrival_method);
        etArrivalTrain = view.findViewById(R.id.et_arrival_train);
        etArrivalTime = view.findViewById(R.id.et_arrival_time);

        btnSubmit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                RegistrationForm form = new RegistrationForm();
                form.setCompany(etCompany.getText().toString());
                form.setName(etName.getText().toString());
                form.setGender(etGender.getText().toString());
                form.setPhone(etPhone.getText().toString());
                form.setEmail(etEmail.getText().toString());
                form.setArrivalMethod(etArrivalMethod.getText().toString());
                form.setArrivalTrain(etArrivalTrain.getText().toString());
                form.setArrivalTime(etArrivalTime.getText().toString());

                // 目前不考虑数据存储，仅提示提交成功
                Toast.makeText(getActivity(), "提交成功", Toast.LENGTH_SHORT).show();
            }
        });

        return view;
    }
}